﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section styles{
    <style>
    </style>

}
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" lay-filter="dictype-form" style="padding: 15px 0 0 0;">
            <input type="hidden" name="Id" value="@Model.Id" />
            <input type="hidden" name="ParentId" value="@Model.ParentId" />
            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">标签名称</label>
                <div class="layui-input-block">
                    <input type="text" name="Dname" lay-verify="required" placeholder="请输入标签名称" autocomplete="off" class="layui-input" value="@Model.Dname">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">对应值</label>
                <div class="layui-input-block">
                    <input type="text" id="Dvalue" @(Model.Id > 0 ? "readonly" : "") name="Dvalue" lay-verify="required" placeholder="请输入对应值"
                           autocomplete="off" class="layui-input @(!string.IsNullOrEmpty(Model.Dvalue)?"readonly-b":"") " value="@Model.Dvalue" />
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">排序</label>
                <div class="layui-input-block">
                    <input type="number" id="Dseq" name="Dseq" placeholder="请输入排序"
                           autocomplete="off" class="layui-input" value="@Model.Dseq" min="0" max="99" />
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">启用</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="isenable" lay-skin="switch" @(Model.Isenable ? "checked" : "")>

                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    描述
                </label>
                <div class="layui-input-block">
                    <textarea name="remark" placeholder="请输入描述" class="layui-textarea">@Model.Remark</textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-hide" lay-submit lay-filter="dicdata-submit" id="dicdata-submit">提交</button>
                </div>
            </div>
        </form>
    </div>
</div>
   


    @section scripts{

        <script type="text/javascript">
            layui.use(['lscom', 'form'], function () {
                var $ = layui.$;
                var lscom = layui.lscom;
                var form = layui.form;

                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.iframeAuto(index);

                window.submitForm = function () {
                    $("#dicdata-submit").click();
                }

                form.on('submit(dicdata-submit)', function (data) {

                    data.field.isenable = data.field.isenable == "on";
                    var field = data.field;
                    var waitIndex = parent.layer.load(2);
                    lscom.ajax({
                        url: "/Systems/Dictionary/SaveDictionary",
                        data: JSON.stringify(field),
                        lsHandleError: false
                    }).done(function (data) {
                        if (data.code == 0) {
                            data.index = index;
                            let parentWindow = parent.selectedWindow().window;
                            parentWindow.saveDataCallback(data);
                        }
                    }).fail(function (message) {
                        lscom.notify.error(message);
                    }).always(function () {
                        parent.layer.close(waitIndex);
                    });

                    return false;
                });
            });
        </script>

    }
